package solutions.leetcode.easy

import solutions.lib.TreeNode

/**
 * @author lizhidong
 * <a href="https://leetcode.cn/problems/evaluate-boolean-binary-tree/">2331. 计算布尔二叉树的值</a>
 */
private class Solution2331 {
    fun evaluateTree(root: TreeNode?): Boolean {
        return if (root == null) false else {
            when(root.`val`) {
                0 -> false
                1 -> true
                2 -> evaluateTree(root.left) or evaluateTree(root.right)
                else -> evaluateTree(root.left) and evaluateTree(root.right)
            }
        }
    }
}

fun main() {
    
}